<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box {
            background-color: black;
            width: 300px;
            height: 300px;

        }
    </style>
</head>


<body>
    <div class="box">广告</div>
    <button>按钮</button>
    <script>
        //元素对象.addEvent....('事件类型'，函数)（类型一定要加引号）
        const btn = document.querySelector('button')
        btn.addEventListener('click', function () {
            alert('起飞咯')
        })
        //一次一次不会循环
        const box = document.querySelector('.box')
        box.addEventListener('click', function () {
            // alert('关闭')
            this.style.display = 'none'

        })

    </script>
</body>

</html>